home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / shadowlib.lha / shadow / Examples / Source / browser.c next >
C/C++ Source or Header  |  1992-11-13  |  75KB  |  2,392 lines

  1. /*
  2.  * Browser Program.
  3.  *
  4.  * å© Copyright 1991, ALl Rights Reserved
  5.  *
  6.  *  David C. Navas
  7.  */
  8. #include <shadow/coreMeta.h>
  9. #include <shadow/coreRoot.h>
  10. #include <shadow/process.h>
  11. #include <shadow/semaphore.h>
  12.  
  13. /*
  14.  * Strings have to be word-aligned -- so add the space at the end,
  15.  * just in case.
  16.  */
  17. #define GUITASK "Browser's Gui Task\0"
  18. #include "/Gui/gui.h"
  19.  
  20. #include <ipc.h>
  21. #include <exec/exec.h>
  22. #include <shadow/shadow_proto.h>
  23. #include <shadow/shadow_pragmas.h>
  24. #include <shadow/method.h>
  25. #include <dos/dostags.h>
  26. #include <clib/alib_protos.h>
  27.  
  28. extern struct ExecBase * __far SysBase;
  29. extern struct IntuitionBase * __far IntuitionBase;
  30. struct Library * __far IPCBase;
  31. struct ShadowBase * __far ShadowBase;
  32. struct DosLibrary * __far DOSBase;
  33. struct UtilityBase * __far UtilityBase;
  34.  
  35. /*
  36.  * external class definitions.
  37.  */
  38. char GuiProcClassName[] = GUIPROCESS_CLASS,
  39.      AslProcClassName[] = ASLPROCESS_CLASS,
  40.      GuiTaskName[] = GUITASK,
  41.      GuiClassName[] = GUI_CLASS,
  42.      WindowClassName[] = WINDOW_CLASS,
  43.      GadgTClassName[] = GADGT_CLASS,
  44.      AslClassName[] = ASL_CLASS;
  45.  
  46. /*
  47.  * Global Variables (non-library).
  48.  */
  49. OBJECT __far GlobalDirector = NULL;
  50. struct Task * __far programTask;
  51. OBJECT programTaskObject = NULL;
  52.  
  53. long __far GlobalNumOpen = 0;
  54.  
  55. /*
  56.  * Function prototypes.
  57.  */
  58. void __regargs *addFromBinNodes(void *, ULONG, struct CWinLocalObjects *);
  59. void LoadBrowser(void);
  60.  
  61.  
  62. /*
  63.  * ==========================================================================
  64.  * =                                                                        =
  65.  * =            Class definition for the BlockClass.                        =
  66.  * =                                                                        =
  67.  * ==========================================================================
  68.  */
  69.  
  70. #define BLOCK_CLASS   "Browser Class"
  71.  
  72. /*
  73.  * Attributes
  74.  */
  75. #define ATTR_BLOCKDIR "director"
  76.  
  77. ATTRIBUTE_TAG blockAttrs[] = {
  78.                                 ATTR_BLOCKDIR, 2 * sizeof(void *), NULL,
  79.                                 TAG_END
  80.                              };
  81.  
  82. /*
  83.  * Methods
  84.  */
  85. BOOL BlockInitMethod(METHOD_ARGS);
  86. void BlockRemoveMethod(METHOD_ARGS);
  87. void BlockNotifyMethod(METHOD_ARGS, long flags,
  88.                                        W_VALUE watcher,
  89.                                        void *first,
  90.                                        void *second,
  91.                                        OBJECT dispatch);
  92. METHOD_TAG blockMethods[] =
  93.                         {
  94.                            {
  95.                               METH_INIT,
  96.                               NULL, NULL,
  97.                               INVOKE_FORCE_SYNC,
  98.                               METH_FLAG_OBJECT, 0,
  99.                               (METHODFUNCTYPE)BlockInitMethod, NULL
  100.                            },
  101.                            {
  102.                               METH_REMOVE,
  103.                               NULL, NULL,
  104.                               INVOKE_FORCE_SYNC,
  105.                               METH_FLAG_OBJECT, 0,
  106.                               (METHODFUNCTYPE)BlockRemoveMethod, NULL
  107.                            },
  108.                            {
  109.                               METH_DIRECTOR_NOTIFY,
  110.                               NULL, NULL,
  111.                               INVOKE_FORCE_ASYNC,
  112.                               METH_FLAG_OBJECT, 0,
  113.                               (METHODFUNCTYPE)BlockNotifyMethod,
  114.                                  REF_NODENOTIFY
  115.                            },
  116.                            TAG_END
  117.                         };
  118.  
  119.  
  120.  
  121. ARGUMENT_TAG REF_HitMethod[] = {'APTR', 4, sizeof(struct GuiIntuiMsg),
  122.                               'JOBJ', 4, SHADOW_OBJECT,
  123.                               TAG_END};
  124. /*
  125.  * ==========================================================================
  126.  * =                                                                        =
  127.  * =       Class definition for the Class Display Window Class.             =
  128.  * =                                                                        =
  129.  * ==========================================================================
  130.  */
  131.  
  132. #define CWIN_CLASS "Window subClass that shows JOBJs"
  133.  
  134. /*
  135.  * Attributes
  136.  */
  137. #define ATTR_LOCALWIN "local objects"
  138.  
  139. struct MyNode {
  140.    struct Node node;
  141.    void *object;
  142. };
  143.  
  144. struct CWinLocalObjects {
  145.    struct MyNode     *lastNode,
  146.                      *nodes;
  147.    struct List       list;
  148.    OBJECT            listObject,
  149.                      object1,
  150.                      object2,
  151.                      object3,
  152.                      object4;
  153.    char              *superClassText;
  154.    OBJECT            director;
  155.    struct MemoryList myMemList;
  156.    META              meta;
  157. };
  158.  
  159. ATTRIBUTE_TAG CWinAttrs[] =
  160.                         {
  161.                            {ATTR_LOCALWIN, sizeof(struct CWinLocalObjects),
  162.                                            NULL},
  163.                            {TAG_END}
  164.                         };
  165.  
  166. /*
  167.  * ArgumentTags
  168.  */
  169. extern ARGUMENT_TAG REF_CWinInitMethod[];
  170.  
  171. /*
  172.  * Methods
  173.  */
  174. void CWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window);
  175. void *CWinInitMethod(METHOD_ARGS, OBJECT parent,
  176.                                   META   meta);
  177. void CWinRemoveMethod(METHOD_ARGS);
  178. void CWinDestroyMethod(METHOD_ARGS);
  179.  
  180. #define METH_GADGET_OPEN_MWIN  "open method display window"
  181. #define METH_GADGET_OPEN_AWIN  "open attr display window"
  182. #define METH_GADGET_OPEN_OWIN  "open object display"
  183.  
  184. void CWinOpenMWinMethod(METHOD_ARGS);
  185. void CWinOpenAWinMethod(METHOD_ARGS);
  186. void CWinOpenOWinMethod(METHOD_ARGS);
  187.  
  188. void CWinNotifyMethod(METHOD_ARGS, long flags,
  189.                                        W_VALUE watcher,
  190.                                        void *first,
  191.                                        void *second);
  192.  
  193. METHOD_TAG CWinMethods[] =
  194.                         {
  195.                            {
  196.                               METH_INIT,
  197.                               NULL, NULL,
  198.                               INVOKE_SYNC,
  199.                               METH_FLAG_OBJECT, 0,
  200.                               CWinInitMethod, REF_CWinInitMethod
  201.                            },
  202.                            {
  203.                               METH_DESTROY,
  204.                               NULL, NULL,
  205.                               INVOKE_SYNC,
  206.                               METH_FLAG_OBJECT, 0,
  207.                               (METHODFUNCTYPE)CWinDestroyMethod, NULL
  208.                            },
  209.                            {
  210.                               METH_REMOVE,
  211.                               NULL, NULL,
  212.                               INVOKE_SYNC,
  213.                               METH_FLAG_OBJECT, 0,
  214.                               (METHODFUNCTYPE)CWinRemoveMethod, NULL
  215.                            },
  216.                            {
  217.                               METH_GADGET_SELECT,
  218.                               NULL, NULL,
  219.                               INVOKE_CALL,
  220.                               METH_FLAG_OBJECT, 0,
  221.                               (METHODFUNCTYPE)CWinHitMethod,
  222.                                  REF_HitMethod
  223.                            },
  224.                            {
  225.                               METH_GADGET_OPEN_MWIN,
  226.                               NULL, NULL,
  227.                               INVOKE_CALL,
  228.                               METH_FLAG_OBJECT, 0,
  229.                               (METHODFUNCTYPE)CWinOpenMWinMethod, NULL
  230.                            },
  231.                            {
  232.                               METH_GADGET_OPEN_AWIN,
  233.                               NULL, NULL,
  234.                               INVOKE_CALL,
  235.                               METH_FLAG_OBJECT, 0,
  236.                               (METHODFUNCTYPE)CWinOpenAWinMethod, NULL
  237.                            },
  238.                            {
  239.                               METH_GADGET_OPEN_OWIN,
  240.                               NULL, NULL,
  241.                               INVOKE_CALL,
  242.                               METH_FLAG_OBJECT, 0,
  243.                               (METHODFUNCTYPE)CWinOpenOWinMethod, NULL
  244.                            },
  245.                            {
  246.                               METH_DIRECTOR_NOTIFY,
  247.                               NULL, NULL,
  248.                               INVOKE_SYNC,
  249.                               METH_FLAG_OBJECT, 0,
  250.                               (METHODFUNCTYPE)CWinNotifyMethod,
  251.                                  REF_NODENOTIFY
  252.                            },
  253.                            TAG_END
  254.                         };
  255.  
  256. /*
  257.  * ==========================================================================
  258.  * =                                                                        =
  259.  * =       Class definition for the Method Display Window Class.            =
  260.  * =                                                                        =
  261.  * ==========================================================================
  262.  */
  263.  
  264. #define METWIN_CLASS "Window subClass that shows Methods"
  265.  
  266. /*
  267.  * Attributes
  268.  */
  269. struct MWinLocalObjects {
  270.    struct MyNode  *lastNode,
  271.                   *nodes;
  272.    struct List    list;
  273.    OBJECT         object1,
  274.                   object2,
  275.                   object3,
  276.                   object4,
  277.                   object5,
  278.                   director;
  279.    CLASS          class;
  280. };
  281.  
  282. ATTRIBUTE_TAG MetWinAttrs[] =
  283.                         {
  284.                            {ATTR_LOCALWIN, sizeof(struct MWinLocalObjects),
  285.                                            NULL},
  286.                            {TAG_END}
  287.                         };
  288.  
  289. /*
  290.  * ArgumentTags
  291.  */
  292. extern ARGUMENT_TAG REF_MetWinInitMethod[],
  293.                   REF_MWinOpenRWinMethod[];
  294.  
  295. /*
  296.  * Methods
  297.  */
  298. void MetWinUpdateInfo(METHOD_ARGS);
  299. void MetWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window);
  300. void *MetWinInitMethod(METHOD_ARGS, OBJECT parent,
  301.                                     CLASS);
  302. void MetWinDestroyMethod(METHOD_ARGS);
  303. void MetWinRemoveMethod(METHOD_ARGS);
  304.  
  305. void MWinOpenRWinMethod(METHOD_ARGS);
  306.  
  307. #define METH_GADGET_OPEN_RWIN "open argument display window"
  308. #define METH_METHOD_UPDATE_INFO "Update Info in Method Window"
  309.  
  310. METHOD_TAG  MetWinMethods[] =
  311.                         {
  312.                            {
  313.                               METH_INIT,
  314.                               NULL, NULL,
  315.                               INVOKE_SYNC,
  316.                               METH_FLAG_OBJECT, 0,
  317.                               MetWinInitMethod, REF_MetWinInitMethod
  318.                            },
  319.                            {
  320.                               METH_DESTROY,
  321.                               NULL, NULL,
  322.                               INVOKE_SYNC,
  323.                               METH_FLAG_OBJECT, 0,
  324.                               (METHODFUNCTYPE)MetWinDestroyMethod, NULL
  325.                            },
  326.                            {
  327.                               METH_REMOVE,
  328.                               NULL, NULL,
  329.                               INVOKE_SYNC,
  330.                               METH_FLAG_OBJECT, 0,
  331.                               (METHODFUNCTYPE)MetWinRemoveMethod, NULL
  332.                            },
  333.                            {
  334.                               METH_GADGET_SELECT,
  335.                               NULL, NULL,
  336.                               INVOKE_CALL,
  337.                               METH_FLAG_OBJECT, 0,
  338.                               (METHODFUNCTYPE)MetWinHitMethod,
  339.                                  REF_HitMethod
  340.                            },
  341.                            {
  342.                               METH_GADGET_OPEN_RWIN,
  343.                               NULL, NULL,
  344.                               INVOKE_CALL,
  345.                               METH_FLAG_OBJECT, 0,
  346.                               (METHODFUNCTYPE)MWinOpenRWinMethod, NULL
  347.                            },
  348.                            {
  349.                               METH_METHOD_UPDATE_INFO,
  350.                               NULL, NULL,
  351.                               INVOKE_SYNC,
  352.                               METH_FLAG_OBJECT, 0,
  353.                               (METHODFUNCTYPE)MetWinUpdateInfo, NULL
  354.                            },
  355.                            TAG_END
  356.                         };
  357.  
  358.  
  359. /*
  360.  * ==========================================================================
  361.  * =                                                                        =
  362.  * =     Class definition for the Attribute Display Window Class.           =
  363.  * =                                                                        =
  364.  * ==========================================================================
  365.  */
  366.  
  367. #define ATTWIN_CLASS "Window subClass that shows Attributes"
  368.  
  369. /*
  370.  * Attributes
  371.  */
  372. struct AWinLocalObjects {
  373.    struct MyNode *lastNode,
  374.                  *nodes;
  375.    struct List   list;
  376.    OBJECT        object1,
  377.                  object2,
  378.                  object3,
  379.                  object4;
  380.    META          meta;
  381. };
  382.  
  383. ATTRIBUTE_TAG AttWinAttrs[] =
  384.                         {
  385.                            {ATTR_LOCALWIN, sizeof(struct AWinLocalObjects),
  386.                                            NULL},
  387.                            {TAG_END}
  388.                         };
  389.  
  390. /*
  391.  * ArgumentTags
  392.  */
  393. extern ARGUMENT_TAG REF_AttWinInitMethod[];
  394.  
  395. /*
  396.  * Methods
  397.  */
  398. void AttWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window);
  399. void *AttWinInitMethod(METHOD_ARGS, OBJECT parent, CLASS);
  400. void AttWinDestroyMethod(METHOD_ARGS);
  401.  
  402. METHOD_TAG AttWinMethods[] =
  403.                         {
  404.                            {
  405.                               METH_INIT,
  406.                               NULL, NULL,
  407.                               INVOKE_SYNC,
  408.                               METH_FLAG_OBJECT, 0,
  409.                               AttWinInitMethod, REF_AttWinInitMethod
  410.                            },
  411.                            {
  412.                               METH_DESTROY,
  413.                               NULL, NULL,
  414.                               INVOKE_SYNC,
  415.                               METH_FLAG_OBJECT, 0,
  416.                               (METHODFUNCTYPE)AttWinDestroyMethod, NULL
  417.                            },
  418.                            {
  419.                               METH_GADGET_SELECT,
  420.                               NULL, NULL,
  421.                               INVOKE_CALL,
  422.                               METH_FLAG_OBJECT, 0,
  423.                               (METHODFUNCTYPE)AttWinHitMethod,
  424.                                  REF_HitMethod
  425.                            },
  426.                            TAG_END
  427.                         };
  428.  
  429.  
  430. /*
  431.  * ==========================================================================
  432.  * =                                                                        =
  433.  * =     Class definition for the ArgumentTag Display Window Class.           =
  434.  * =                                                                        =
  435.  * ==========================================================================
  436.  */
  437.  
  438. #define REFWIN_CLASS "Window subClass that shows ArgumentTags"
  439.  
  440. /*
  441.  * Attributes
  442.  */
  443. struct RWinLocalObjects {
  444.    struct MyNode  *lastNode,
  445.                   *nodes;
  446.    struct List    list;
  447.    OBJECT         object1,
  448.                   object2;
  449.    char           *text;
  450. };
  451.  
  452. ATTRIBUTE_TAG RefWinAttrs[] =
  453.                         {
  454.                            {ATTR_LOCALWIN, sizeof(struct RWinLocalObjects),
  455.                                            NULL},
  456.                            {TAG_END}
  457.                         };
  458.  
  459. /*
  460.  * ArgumentTags
  461.  */
  462. extern ARGUMENT_TAG REF_RefWinInitMethod[];
  463.  
  464. /*
  465.  * Methods
  466.  */
  467. void RefWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window);
  468. void *RefWinInitMethod(METHOD_ARGS, OBJECT parent,
  469.                                     struct MethodHandler *,
  470.                                     CLASS  mclass);
  471. void RefWinDestroyMethod(METHOD_ARGS);
  472.  
  473. METHOD_TAG RefWinMethods[] =
  474.                         {
  475.                            {
  476.                               METH_INIT,
  477.                               NULL, NULL,
  478.                               INVOKE_SYNC,
  479.                               METH_FLAG_OBJECT, 0,
  480.                               RefWinInitMethod, REF_RefWinInitMethod
  481.                            },
  482.                            {
  483.                               METH_DESTROY,
  484.                               NULL, NULL,
  485.                               INVOKE_SYNC,
  486.                               METH_FLAG_OBJECT, 0,
  487.                               (METHODFUNCTYPE)RefWinDestroyMethod, NULL
  488.                            },
  489.                            {
  490.                               METH_GADGET_SELECT,
  491.                               NULL, NULL,
  492.                               INVOKE_CALL,
  493.                               METH_FLAG_OBJECT, 0,
  494.                               (METHODFUNCTYPE)RefWinHitMethod,
  495.                                  REF_HitMethod
  496.                            },
  497.                            TAG_END
  498.                         };
  499.  
  500.  
  501. /*
  502.  * ==========================================================================
  503.  * =                                                                        =
  504.  * =                    F  U  N  C  T  I  O  N  S                           =
  505.  * =                                                                        =
  506.  * ==========================================================================
  507.  */
  508.  
  509. /*
  510.  * ^C -- just say no.
  511.  */
  512. int CXBRK(void)
  513. {
  514.    return(0);
  515. }
  516.  
  517. /*
  518.  * no!
  519.  */
  520. chkabort(void)
  521. {
  522.    return(0);
  523. }
  524.  
  525. /*
  526.  * Okay, here's the main.
  527.  */
  528. void main(void)
  529. {
  530.  
  531.    programTask = FindTask(NULL);
  532.  
  533.    /*
  534.     * Open Libraries and startup the program for SHADOW.
  535.     */
  536.    if (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37))
  537.    {
  538.       if (IPCBase = OpenLibrary("ppipc.library", 0))
  539.       {
  540.          if (ShadowBase = (struct ShadowBase *)
  541.                           OpenLibrary("shadow.library", 5))
  542.          {
  543.             if (InitOOProgram("Browser Program"))
  544.             {
  545.                programTaskObject = CurrentProcess();
  546.                /*
  547.                 * Okay, run the Browser.
  548.                 */
  549.                LoadBrowser();
  550.                RemoveCurrentProgram(NULL);
  551.             } else
  552.                VPrintf("Can't init Browser program.\n", NULL);
  553.  
  554.             CloseLibrary(ShadowBase);
  555.          } else
  556.             VPrintf("requires shadow.library V5.x in libs:\n", NULL);
  557.  
  558.          CloseLibrary(IPCBase);
  559.       } else
  560.          VPrintf("requires ppipc.library in libs:\n", NULL);
  561.    } else
  562.    {
  563.       DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 0);
  564.       Write(Output(), "Sorry, use 2.0\n", 15);
  565.    }
  566.    CloseLibrary(DOSBase);
  567. }
  568.  
  569. void LoadBrowser(void)
  570. {
  571.    OBJECT    guiTask;
  572.    W_AVLTREE wbt;
  573.    int success;
  574.  
  575. #ifndef NDEBUG
  576.    ULONG args[10];
  577.    long mem2;
  578.  
  579.    args[0] = mem2 = AvailMem(MEMF_ANY);
  580. #endif
  581.  
  582.    /*
  583.     * Have we already started a browser ???
  584.     * if so, we can just send it a method and shut ourselves down.
  585.     */
  586.    PSemString("Browser Program", SSEM_LOCK);
  587.    if (CreateInstance(NULL, BLOCK_CLASS, META_CLASS, METHOD_END))
  588.    {
  589.       VSemString("Browser Program");
  590.       return;
  591.    }
  592.  
  593.    /*
  594.     * Initialize the GUI
  595.     */
  596.    success = InitGUISystem();
  597. #ifndef NDEBUG
  598.    VPrintf("MemStart %ld\n", args);
  599. #endif
  600.  
  601.    if (wbt = FindAttribute(programTaskObject, ATTR_RESOURCETREE))
  602.       guiTask = FindWatchedTreeStringNode(wbt, GUITASK);
  603.    else
  604.       guiTask = NULL;
  605.  
  606.    SetupMethodTags(CWinMethods, guiTask, (void *)-1);
  607.    SetupMethodTags(MetWinMethods, guiTask, (void *)-1);
  608.    SetupMethodTags(AttWinMethods, guiTask, (void *)-1);
  609.    SetupMethodTags(RefWinMethods, guiTask, (void *)-1);
  610.    SetupMethodTags(blockMethods, guiTask, (void *)-1);
  611.  
  612.    DropObject(guiTask);
  613.  
  614.    /*
  615.     * Create BlockClass.
  616.     */
  617.  
  618.    success &= AddAutoResource(NULL,
  619.                               CreateSubClass(NULL,
  620.                                              GUI_CLASS,
  621.                                              META_CLASS,
  622.                                              BLOCK_CLASS,
  623.                                              NULL,
  624.                                              blockAttrs,
  625.                                              blockMethods,
  626.                                              METHOD_END),
  627.                               BLOCK_CLASS);
  628.  
  629.    VSemString("Browser Program");
  630.  
  631.    /*
  632.     * Create the window classes.
  633.     */
  634.    success &= AddAutoResource(NULL,
  635.                               CreateSubClass(NULL,
  636.                                             WINDOW_CLASS,
  637.                                             META_CLASS,
  638.                                             CWIN_CLASS,
  639.                                             NULL,
  640.                                             CWinAttrs,
  641.                                             CWinMethods,
  642.                                             METHOD_END),
  643.                               CWIN_CLASS);
  644.  
  645.    success &= AddAutoResource(NULL,
  646.                               CreateSubClass(NULL,
  647.                                              WINDOW_CLASS,
  648.                                              META_CLASS,
  649.                                              METWIN_CLASS,
  650.                                              NULL,
  651.                                              MetWinAttrs,
  652.                                              MetWinMethods,
  653.                                              METHOD_END),
  654.                               METWIN_CLASS);
  655.  
  656.    success &= AddAutoResource(NULL,
  657.                               CreateSubClass(NULL,
  658.                                              WINDOW_CLASS,
  659.                                              META_CLASS,
  660.                                              ATTWIN_CLASS,
  661.                                              NULL,
  662.                                              AttWinAttrs,
  663.                                              AttWinMethods,
  664.                                              METHOD_END),
  665.                               ATTWIN_CLASS);
  666.  
  667.    success &= AddAutoResource(NULL,
  668.                               CreateSubClass(NULL,
  669.                                              WINDOW_CLASS,
  670.                                              META_CLASS,
  671.                                              REFWIN_CLASS,
  672.                                              NULL,
  673.                                              RefWinAttrs,
  674.                                              RefWinMethods,
  675.                                              METHOD_END),
  676.                               REFWIN_CLASS);
  677.  
  678.    /*
  679.     * Create the top level window.
  680.     */
  681.    success &= (BOOL)CreateInstance(NULL, BLOCK_CLASS, META_CLASS, METHOD_END);
  682.  
  683.  
  684. #ifndef NDEBUG
  685.    args[0] = mem2 - AvailMem(MEMF_ANY);
  686.  
  687.    VPrintf("Memory Usage %ld\n", args);
  688. #endif
  689.  
  690.  
  691.    /*
  692.     * basically Wait for everything to shut down.
  693.     *
  694.     * Nothing is actually going to use these ports, but they ARE
  695.     *  allocated, so I might as well use them.
  696.     */
  697.    if (success)
  698.    {
  699.       HandleMessages();
  700.    }
  701.  
  702. #ifndef NDEBUG
  703.    args[0] = AvailMem(MEMF_ANY);
  704.    VPrintf("MemEnd %ld\n", args);
  705. #endif
  706. }
  707.  
  708.  
  709. /*
  710.  * Add all of the objects into the list....
  711.  */
  712. void __regargs *addFromBinNodes(void *value,
  713.                                 ULONG name,
  714.                                 struct CWinLocalObjects *local)
  715. {
  716.    struct MyNode *node;
  717.  
  718.    if (!(node = AllocateItem(&local->myMemList)))
  719.       return (void *)-1;
  720.  
  721.    if (name == (long)value)
  722.    {
  723.       char buffer[20];
  724.       long name2;
  725.  
  726.       name2 = name;
  727.  
  728.       RawDoFmt("Object at: %lx", &name2, SprintfCallback, buffer);
  729.       node->node.ln_Name = UseString(buffer);
  730.    }
  731.    else
  732.       node->node.ln_Name = UseString((char *)name);
  733.  
  734.    /*
  735.     * The object might reference this CWindow.
  736.     *  THEREFORE, it hangs, unless reference removed during remove
  737.     *   method, as opposed to DESTROY method.
  738.     *   [Because DESTROY would never get called, it self-references.]
  739.     */
  740.  
  741.    node->object = value;
  742.    UseObject(value);
  743.  
  744.    AddTail(&local->list, node);
  745.    return NULL;
  746. }
  747.  
  748.  
  749. /*
  750.  * ==========================================================================
  751.  * =                                                                        =
  752.  * =            ALL OF THE CLASS METHODS ARE BELOW.                         =
  753.  * =                                                                        =
  754.  * ==========================================================================
  755.  */
  756.  
  757. /*
  758.  * Block Class methods.
  759.  */
  760. BOOL BlockInitMethod(METHOD_ARGS)
  761. {
  762.    OBJECT *director, handle;
  763.  
  764.    director = FindAttribute(object, ATTR_BLOCKDIR);
  765.  
  766.    if (CallSuper())
  767.    {
  768.       OBJECT window;
  769.       CLASS  windowClass;
  770.  
  771.       /*
  772.        * Create the example Global Director which watches all of the
  773.        *  window classes' GUICHILDREN attribute.
  774.        */
  775.       if (!GlobalDirector)
  776.       {
  777.          /*
  778.           * Get a director object.
  779.           */
  780.          GlobalDirector = CreateInstance(NULL,
  781.                                          DIRECTOR_CLASS,
  782.                                          META_CLASS,
  783.                                          "WatchWindows",
  784.                                          object,
  785.                                          METH_DIRECTOR_NOTIFY,
  786.                                          (W_INSERT_NODE | W_REMOVE) |
  787.                                            (SHADOW_CLASS << 16) |
  788.                                            W_FLAG_AUTOBREAK  |
  789.                                            W_FLAG_AUTOREMOVE,
  790.                                          METHOD_END);
  791.  
  792.          /*
  793.           * Establish the actual connection.  We don't care if
  794.           * it doesn't actually Open, so that makes things easier.
  795.           *
  796.           * We are watching all the ATTR_GUICHILDREN of every instance
  797.           *  whose class is a subclass of WINDOW_CLASS
  798.           */
  799.          windowClass = FindShadowClass(WINDOW_CLASS);
  800.          DropObject(DoShadow(GlobalDirector,
  801.                                  NULL,
  802.                                  METH_DIRECTOR_ESTABLISH,
  803.                                  ATTR_GUICHILDREN,
  804.                                  windowClass,
  805.                                  METHOD_END));
  806.          DropObject(windowClass);
  807.  
  808.          /*
  809.           * Why is this at priority one?
  810.           * Well, there's this race condition....  You can either shut
  811.           *  this down FIRST, or you can make the notification in
  812.           *  CWIN ASYNC.  I like this better.
  813.           */
  814.          AddAutoResource(programTaskObject, GlobalDirector, (char *)1);
  815.       }
  816.  
  817.  
  818.       /*
  819.        * Create the director to watch the children of this object.
  820.        *
  821.        * When this object's children reaches zero, this object
  822.        *  should GO AWAY!
  823.        */
  824.  
  825.       *director = CreateInstance(NULL,
  826.                                  DIRECTOR_CLASS,
  827.                                  META_CLASS,
  828.                                  "WatchBlockedChildren",
  829.                                  object,
  830.                                  METH_DIRECTOR_NOTIFY,
  831.                                  (W_INSERT_NODE | W_REMOVE) |
  832.                                    (SHADOW_OBJECT << 16) |
  833.                                    W_FLAG_AUTOBREAK |
  834.                                    W_FLAG_AUTOREMOVE,
  835.                                  METHOD_END);
  836.       /*
  837.        * Establish the conection for the director.
  838.        */
  839.       if (handle = DoShadow(*director, NULL, METH_DIRECTOR_ESTABLISH,
  840.                                         ATTR_GUICHILDREN,
  841.                                         object,
  842.                                         METHOD_END))
  843.       {
  844.          DropObject(handle);
  845.          if (window = CreateInstance(NULL,
  846.                                      CWIN_CLASS,
  847.                                      META_CLASS,
  848.                                      object,
  849.                                      METHOD_END))
  850.          {
  851.             DropObject(window);
  852.             if (AddAutoResource(programTaskObject, object, NULL))
  853.             {
  854.                GlobalNumOpen++;
  855.                return TRUE;
  856.             }
  857.          }
  858.       }
  859.       RemoveObject(object);
  860.    }
  861.    return FALSE;
  862. }
  863.  
  864. void BlockRemoveMethod(METHOD_ARGS)
  865. {
  866.    OBJECT director;
  867.  
  868.    DropObject(RemoveAutoResource(programTaskObject, object, NULL));
  869.  
  870.    director = SetObject(FindAttribute(object, ATTR_BLOCKDIR), NULL);
  871.    RemoveObject(director);
  872.  
  873.    CallSuper();
  874.  
  875.    if (!--GlobalNumOpen)
  876.       Signal(programTask, SIGBREAKF_CTRL_C);
  877. }
  878.  
  879. void BlockNotifyMethod(METHOD_ARGS, long flags,
  880.                                        W_VALUE  watcher,
  881.                                        void *first,
  882.                                        void *second,
  883.                                        OBJECT dispatch)
  884. {
  885.    long *director;
  886.  
  887.    director = FindAttribute(object, ATTR_BLOCKDIR);
  888.    if (!second)  second = "";
  889.  
  890.    if (dispatch == GlobalDirector)
  891.    {
  892.       if (flags & W_INSERT)
  893.       {
  894.          VPrintf("Inserted child <%s> into some Window Object.\n",
  895.                   (ULONG *)&second);
  896.       } else
  897.       {
  898.          VPrintf("Removed child <%s> from some Window Object.\n",
  899.                   (ULONG *)&second);
  900.       }
  901.    } else
  902.    {
  903.       if (flags & W_INSERT)
  904.          (director[1])++;
  905.       else if (!(--(director[1])))
  906.       {
  907.          RemoveObject(UseObject(object));
  908.       }
  909.    }
  910. }
  911.  
  912. /*
  913.  * CWin Class methods.
  914.  */
  915. ARGUMENT_TAG REF_CWinInitMethod[] = {
  916.                                      {'JOBJ', sizeof(void *), SHADOW_OBJECT},
  917.                                      {'JOBJ', sizeof(void *), SHADOW_CLASS},
  918.                                      {TAG_END, SHADOW_RETURN_OBJECT, 0}
  919.                                   };
  920. void *CWinInitMethod(METHOD_ARGS, OBJECT parent,
  921.                                   META meta)
  922. {
  923.    struct CWinLocalObjects *mlo;
  924.  
  925.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  926.    NewList(&mlo->list);
  927.    if (!(InitTable(&mlo->myMemList, NULL, NULL, sizeof(struct MyNode))))
  928.    {
  929.       UseObject(object);
  930.       DropObject(object);
  931.       return NULL;
  932.    }
  933.  
  934.    /*
  935.     * Create the correct window with the correct title....
  936.     */
  937.    {
  938.       struct TagItem tag[8];
  939.       char *string;
  940.  
  941.       {
  942.          char buffer[128];
  943.  
  944.          if (!meta)
  945.             strcpy(buffer, "Meta list for system");
  946.          else if (meta->meta_class == meta)
  947.          {
  948.             strcpy(buffer, "Class list for: ");
  949.             strncat(buffer, meta->meta_name, 64);
  950.          } else
  951.          {
  952.             strcpy(buffer, "Object list for: ");
  953.             strncat(buffer, meta->meta_name, 64);
  954.          }
  955.          if (!(string = UseString(buffer)))
  956.          {
  957.             UseObject(object);
  958.             DropObject(object);
  959.             return NULL;
  960.          }
  961.       }
  962.  
  963.       tag[0].ti_Tag = WA_Width;
  964.       tag[0].ti_Data = 500;
  965.       tag[1].ti_Tag = WA_Height;
  966.       tag[1].ti_Data = 200;
  967.       tag[2].ti_Tag = WA_MinWidth;
  968.       tag[2].ti_Data = 60;
  969.       tag[3].ti_Tag = WA_MinHeight;
  970.       tag[3].ti_Data = 40;
  971.       tag[4].ti_Tag = WA_MaxWidth;
  972.       tag[4].ti_Data = -1;
  973.       tag[5].ti_Tag = WA_MaxHeight;
  974.       tag[5].ti_Data = -1;
  975.       tag[6].ti_Tag = WA_SimpleRefresh;
  976.       tag[6].ti_Data = TRUE;
  977.       tag[7].ti_Tag = TAG_END;
  978.  
  979.       object = DoSuperShadow(object, class, METH_INIT,
  980.                                             parent,
  981.                                             string,
  982.                                             NULL,
  983.                                             NULL,
  984.                                             tag,
  985.                                             METHOD_END);
  986.       DropString(string);
  987.       if (!object)
  988.          return NULL;
  989.    }
  990.  
  991.    mlo->meta = UseObject(meta);
  992.  
  993.    /*
  994.     * So watch the tree....
  995.     */
  996.    /*
  997.     * Create the watching director object.
  998.     */
  999.    mlo->director = CreateInstance(NULL,
  1000.                                   DIRECTOR_CLASS,
  1001.                                   META_CLASS,
  1002.                                   "Watch Meta",
  1003.                                   object,
  1004.                                   METH_DIRECTOR_NOTIFY,
  1005.                                   (W_INSERT_NODE | W_REMOVE) |
  1006.                                     (SHADOW_OBJECT << 16) |
  1007.                                     W_FLAG_AUTOBREAK |
  1008.                                     W_FLAG_AUTOREMOVE,
  1009.                                   METHOD_END);
  1010.  
  1011.    /*
  1012.     * Establish the connection.
  1013.     */
  1014.    DropObject( DoShadow(mlo->director,
  1015.                             NULL,
  1016.                             METH_DIRECTOR_ESTABLISH,
  1017.                             (meta)?(void *)ATTR_INSTANCETREE:
  1018.                                    (void *)&ShadowBase->sb_metaTree,
  1019.                             meta,
  1020.                             METHOD_END));
  1021.  
  1022.  
  1023.    /*
  1024.     * Copy all the instance objects into the list.
  1025.     */
  1026.    {
  1027.       W_AVLTREE tree;
  1028.  
  1029.       tree = (meta)?(W_AVLTREE)FindAttribute(meta, ATTR_INSTANCETREE):
  1030.                     &ShadowBase->sb_metaTree;
  1031.       DoInOrderTree(&tree->wv_value, addFromBinNodes, mlo);
  1032.       mlo->lastNode = NULL;
  1033.    }
  1034.  
  1035.    /*
  1036.     * Okay, we have a window.  Now we need gadgets.
  1037.     */
  1038.    {
  1039.       struct TagItem tag[3];
  1040.       struct NewGadget ng;
  1041.  
  1042.       ng.ng_LeftEdge = 50;
  1043.       ng.ng_TopEdge = 45;
  1044.       ng.ng_Width = 300;
  1045.       ng.ng_Height = 90;
  1046.       ng.ng_Flags = PLACETEXT_ABOVE;
  1047.       tag[0].ti_Tag = GTLV_Labels;
  1048.       tag[0].ti_Data = (ULONG)&mlo->list;
  1049.  
  1050.       if (!meta || meta->meta_class == meta)
  1051.          tag[1].ti_Tag = GTLV_ShowSelected;
  1052.       else
  1053.          tag[1].ti_Tag = 0;
  1054.  
  1055.       tag[1].ti_Data = NULL;
  1056.       tag[2].ti_Tag = TAG_END;
  1057.       mlo->listObject = CreateInstance(NULL,
  1058.                                        GADGT_CLASS,
  1059.                                        META_CLASS,
  1060.                                        object,
  1061.                                        (meta)?((meta->meta_class == meta)?
  1062.                                                              "Class List:":
  1063.                                                              "Instances:")
  1064.                                              :"Meta List:",
  1065.                                        (!meta || meta->meta_class == meta)?
  1066.                                           object:NULL,
  1067.                                        METH_GADGET_SELECT,
  1068.                                        &ng,
  1069.                                        LISTVIEW_KIND,
  1070.                                        tag,
  1071.                                        METHOD_END);
  1072.  
  1073.       if (meta && (meta->meta_class != meta))
  1074.          return object;
  1075.  
  1076.       ng.ng_TopEdge += ng.ng_Height;
  1077.       ng.ng_Height = 15;
  1078.       ng.ng_Width = 80;
  1079.       ng.ng_Flags = PLACETEXT_RIGHT;
  1080.       tag[0].ti_Tag = TAG_END;
  1081.       mlo->object1 = CreateInstance(NULL,
  1082.                                     GADGT_CLASS,
  1083.                                     META_CLASS,
  1084.                                     object,
  1085.                                     ":Instance size",
  1086.                                     object,
  1087.                                     METH_GADGET_SELECT,
  1088.                                     &ng,
  1089.                                     NUMBER_KIND,
  1090.                                     tag,
  1091.                                     METHOD_END);
  1092.  
  1093.       ng.ng_TopEdge += ng.ng_Height;
  1094.       ng.ng_Height = 15;
  1095.       ng.ng_Width = 80;
  1096.       ng.ng_Flags = PLACETEXT_RIGHT;
  1097.       tag[0].ti_Tag = TAG_END;
  1098.       mlo->object2 = CreateInstance(NULL,
  1099.                                     GADGT_CLASS,
  1100.                                     META_CLASS,
  1101.                                     object,
  1102.                                     ":methodTable size",
  1103.                                     object,
  1104.                                     METH_GADGET_SELECT,
  1105.                                     &ng,
  1106.                                     NUMBER_KIND,
  1107.                                     tag,
  1108.                                     METHOD_END);
  1109.  
  1110.       ng.ng_TopEdge += ng.ng_Height;
  1111.       ng.ng_Height = 15;
  1112.       ng.ng_Width = 80;
  1113.       ng.ng_Flags = PLACETEXT_RIGHT;
  1114.       tag[0].ti_Tag = TAG_END;
  1115.       mlo->object3 = CreateInstance(NULL,
  1116.                                     GADGT_CLASS,
  1117.                                     META_CLASS,
  1118.                                     object,
  1119.                                     ":attributeTable size",
  1120.                                     object,
  1121.                                     METH_GADGET_SELECT,
  1122.                                     &ng,
  1123.                                     NUMBER_KIND,
  1124.                                     tag,
  1125.                                     METHOD_END);
  1126.  
  1127.       ng.ng_TopEdge += ng.ng_Height;
  1128.       ng.ng_Height = 15;
  1129.       ng.ng_Width = 80;
  1130.       ng.ng_Flags = PLACETEXT_RIGHT;
  1131.       tag[0].ti_Tag = TAG_END;
  1132.       mlo->object4 = CreateInstance(NULL,
  1133.                                     GADGT_CLASS,
  1134.                                     META_CLASS,
  1135.                                     object,
  1136.                                     NULL,
  1137.                                     object,
  1138.                                     METH_GADGET_SELECT,
  1139.                                     &ng,
  1140.                                     TEXT_KIND,
  1141.                                     tag,
  1142.                                     METHOD_END);
  1143.  
  1144.       ng.ng_TopEdge = 45;
  1145.       ng.ng_LeftEdge = 370;
  1146.       ng.ng_Height = 20;
  1147.       ng.ng_Width = 100;
  1148.       ng.ng_Flags = 0;
  1149.       tag[0].ti_Tag = TAG_END;
  1150.       DropObject(CreateInstance(NULL,
  1151.                                 GADGT_CLASS,
  1152.                                 META_CLASS,
  1153.                                 object,
  1154.                                 "Methods",
  1155.                                 object,
  1156.                                 METH_GADGET_OPEN_MWIN,
  1157.                                 &ng,
  1158.                                 BUTTON_KIND,
  1159.                                 tag,
  1160.                                 METHOD_END));
  1161.  
  1162.       ng.ng_TopEdge += ng.ng_Height;
  1163.       ng.ng_Height = 20;
  1164.       ng.ng_Width = 100;
  1165.       ng.ng_Flags = 0;
  1166.       tag[0].ti_Tag = TAG_END;
  1167.       DropObject(CreateInstance(NULL,
  1168.                                 GADGT_CLASS,
  1169.                                 META_CLASS,
  1170.                                 object,
  1171.                                 "Attributes",
  1172.                                 object,
  1173.                                 METH_GADGET_OPEN_AWIN,
  1174.                                 &ng,
  1175.                                 BUTTON_KIND,
  1176.                                 tag,
  1177.                                 METHOD_END));
  1178.  
  1179.       ng.ng_TopEdge += ng.ng_Height;
  1180.       ng.ng_Height = 20;
  1181.       ng.ng_Width = 100;
  1182.       ng.ng_Flags = 0;
  1183.       tag[0].ti_Tag = TAG_END;
  1184.       DropObject(CreateInstance(NULL,
  1185.                                 GADGT_CLASS,
  1186.                                 META_CLASS,
  1187.                                 object,
  1188.                                 "Instances",
  1189.                                 object,
  1190.                                 METH_GADGET_OPEN_OWIN,
  1191.                                 &ng,
  1192.                                 BUTTON_KIND,
  1193.                                 tag,
  1194.                                 METHOD_END));
  1195.    }
  1196.    return object;
  1197. }
  1198.  
  1199. void CWinNotifyMethod(METHOD_ARGS, long flags,
  1200.                                        W_VALUE watcher,
  1201.                                        void *first,
  1202.                                        void *second)
  1203. {
  1204.    struct CWinLocalObjects *mlo;
  1205.    struct TagItem tags[2];
  1206.    struct MyNode *node;
  1207.  
  1208.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1209.    if (!mlo->director)
  1210.       return;
  1211.  
  1212.    tags[0].ti_Tag = GTLV_Labels;
  1213.    tags[0].ti_Data = ~0;
  1214.    tags[1].ti_Tag = TAG_END;
  1215.    DoShadow(mlo->listObject, NULL, METH_GADGET_CHANGE,
  1216.                                           tags,
  1217.                                           METHOD_END);
  1218.    if (flags & W_INSERT)
  1219.    {
  1220.  
  1221.       if (!(node = AllocateItem(&mlo->myMemList)))
  1222.          return;
  1223.       if (second != first)
  1224.       {
  1225.          node->node.ln_Name = UseString((char *)second);
  1226.       } else
  1227.       {
  1228.          char buffer[20];
  1229.  
  1230.          RawDoFmt("Object at: %lx", &first, SprintfCallback, buffer);
  1231.  
  1232.          node->node.ln_Name = UseString(buffer);
  1233.       }
  1234.  
  1235.       node->object = first;
  1236.       UseObject(first);
  1237.       AddTail(&mlo->list, node);
  1238.    } else if (flags & W_REMOVE)
  1239.    {
  1240.       char *name;
  1241.  
  1242.       if (second != first)
  1243.       {
  1244.          name = FindString((char *)second);
  1245.       } else
  1246.       {
  1247.          char buffer[20];
  1248.  
  1249.          RawDoFmt("Object at: %lx", &first, SprintfCallback, buffer);
  1250.          name = FindString(buffer);
  1251.       }
  1252.       for(node = (struct MyNode *)mlo->list.lh_Head;
  1253.           node->node.ln_Succ;
  1254.           node = (struct MyNode *)node->node.ln_Succ)
  1255.       {
  1256.          if (node->node.ln_Name == name && node->object == first)
  1257.          {
  1258.             QuickDropString(name);
  1259.             DropObject(first);
  1260.             Remove(node);
  1261.             FreeItem(&mlo->myMemList, node);
  1262.             if (mlo->lastNode == node)
  1263.                mlo->lastNode = NULL;
  1264.             break;
  1265.          }
  1266.       }
  1267.    }
  1268.    tags[0].ti_Tag = GTLV_Labels;
  1269.    tags[0].ti_Data = (ULONG)&mlo->list;
  1270.    DoShadow(mlo->listObject, NULL, METH_GADGET_CHANGE,
  1271.                                           tags,
  1272.                                           METHOD_END);
  1273. }
  1274.  
  1275. void CWinRemoveMethod(METHOD_ARGS)
  1276. {
  1277.    struct CWinLocalObjects *mlo;
  1278.    struct Node *node;
  1279.  
  1280.  
  1281.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1282.    RemoveObject(SetObject(&mlo->director, NULL));
  1283.  
  1284.    node = mlo->list.lh_Head;
  1285.  
  1286.    UseObject(object);         /* Make sure object stays around! */
  1287.    CallSuper();               /* Let GadTools know to get rid of gadgets. */
  1288.  
  1289.    NewList(&mlo->list);
  1290.    for(; node->ln_Succ; node = node->ln_Succ)
  1291.    {
  1292.       DropObject(((struct MyNode *)node)->object);
  1293.       QuickDropString(node->ln_Name);
  1294.    }
  1295.    DropObject(object);        /* OKAY, now we're done! */
  1296. }
  1297.  
  1298. void CWinDestroyMethod(METHOD_ARGS)
  1299. {
  1300.    struct CWinLocalObjects *mlo;
  1301.  
  1302.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1303.    DropObject(mlo->object1);
  1304.    DropObject(mlo->object2);
  1305.    DropObject(mlo->object3);
  1306.    DropObject(mlo->object4);
  1307.    DropObject(mlo->listObject);
  1308.    DropObject(mlo->meta);
  1309.    QuickDropString(mlo->superClassText);
  1310.  
  1311.    FreeTable(&mlo->myMemList);
  1312.    CallSuper();
  1313. }
  1314.  
  1315.  
  1316. /*
  1317.  * Selected a new item in the list.
  1318.  * So update all of our information.
  1319.  * Only called if this is a class information window -- not for an
  1320.  *  instances window.
  1321.  */
  1322.  
  1323. void CWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window)
  1324. {
  1325.    struct CWinLocalObjects *mlo;
  1326.    META   meta;
  1327.    struct TagItem tags[2];
  1328.    long code = (info)?info->gii_Code:0;
  1329.  
  1330.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1331.  
  1332.    {
  1333.       struct Node *node;
  1334.  
  1335.       for(node = mlo->list.lh_Head; code; --code)
  1336.          node = node->ln_Succ;
  1337.       mlo->lastNode = (struct MyNode *)node;
  1338.    }
  1339.  
  1340.    /*
  1341.     * Instance size gadget.
  1342.     */
  1343.    tags[0].ti_Tag = GTNM_Number;
  1344.    tags[0].ti_Data = ((META)(mlo->lastNode->object))->meta_size;
  1345.    tags[1].ti_Tag = TAG_END;
  1346.    DoShadow(mlo->object1, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1347.  
  1348.    /*
  1349.     * Method table size in bytes.
  1350.     */
  1351.    tags[0].ti_Data = ((META)
  1352.                       (mlo->lastNode->object))->meta_verbs.mt_num *
  1353.                      sizeof(struct MethodHandler);
  1354.    DoShadow(mlo->object2, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1355.  
  1356.    /*
  1357.     * Attribute table size in bytes.
  1358.     */
  1359.    tags[0].ti_Data = ((META)
  1360.                       (mlo->lastNode->object))->meta_attributes.att_num *
  1361.                      sizeof(struct Attribute);
  1362.    DoShadow(mlo->object3, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1363.  
  1364.    /*
  1365.     * superClass name.
  1366.     */
  1367.    tags[0].ti_Tag = GTTX_Text;
  1368.    meta = ((META)(mlo->lastNode->object))->meta_superClass;
  1369.    if (meta)
  1370.    {
  1371.       QuickDropString(mlo->superClassText);
  1372.  
  1373.       tags[0].ti_Data = (ULONG)(mlo->superClassText =
  1374.                         UseString(meta->meta_name));
  1375.    }
  1376.    else
  1377.       tags[0].ti_Data = 0L;
  1378.    DoShadow(mlo->object4, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1379. }
  1380.  
  1381. void CWinOpenMWinMethod(METHOD_ARGS)
  1382. {
  1383.    struct CWinLocalObjects *mlo;
  1384.    struct GUIStruct *gui;
  1385.  
  1386.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1387.    gui = FindAttribute(object, ATTR_GUISTRUCT);
  1388.  
  1389.    if (!mlo->lastNode)
  1390.       return;
  1391.  
  1392.    DropObject(CreateInstance(NULL,
  1393.                              METWIN_CLASS,
  1394.                              META_CLASS,
  1395.                              gui->gui_parent,
  1396.                              mlo->lastNode->object,
  1397.                              METHOD_END));
  1398. }
  1399.  
  1400. void CWinOpenAWinMethod(METHOD_ARGS)
  1401. {
  1402.    struct CWinLocalObjects *mlo;
  1403.    struct GUIStruct *gui;
  1404.  
  1405.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1406.    gui = FindAttribute(object, ATTR_GUISTRUCT);
  1407.  
  1408.    if (!mlo->lastNode)
  1409.       return;
  1410.  
  1411.    DropObject(CreateInstance(NULL,
  1412.                              ATTWIN_CLASS,
  1413.                              META_CLASS,
  1414.                              gui->gui_parent,
  1415.                              mlo->lastNode->object,
  1416.                              METHOD_END));
  1417. }
  1418.  
  1419. void CWinOpenOWinMethod(METHOD_ARGS)
  1420. {
  1421.    struct CWinLocalObjects *mlo;
  1422.    struct GUIStruct *gui;
  1423.  
  1424.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1425.    gui = FindAttribute(object, ATTR_GUISTRUCT);
  1426.  
  1427.    if (!mlo->lastNode)
  1428.       return;
  1429.  
  1430.    DropObject(CreateInstance(NULL,
  1431.                              CWIN_CLASS,
  1432.                              META_CLASS,
  1433.                              gui->gui_parent,
  1434.                              mlo->lastNode->object,
  1435.                              METHOD_END));
  1436. }
  1437.  
  1438. /*
  1439.  * MetWin Class methods.
  1440.  */
  1441. ARGUMENT_TAG REF_MetWinInitMethod[] = {
  1442.                                        {'JOBJ', sizeof(void *),
  1443.                                                 SHADOW_OBJECT},
  1444.                                        {'JOBJ', sizeof(void *),
  1445.                                                 SHADOW_CLASS},
  1446.                                        {TAG_END, SHADOW_RETURN_OBJECT, 0}
  1447.                                     };
  1448. void *MetWinInitMethod(METHOD_ARGS, OBJECT parent,
  1449.                                     CLASS theClass)
  1450. {
  1451.    struct NewGadget ng;
  1452.    struct TagItem tag[8];
  1453.    struct MWinLocalObjects *mlo;
  1454.    char buffer[128];
  1455.  
  1456.    tag[0].ti_Tag = WA_Width;
  1457.    tag[0].ti_Data = 500;
  1458.    tag[1].ti_Tag = WA_Height;
  1459.    tag[1].ti_Data = 200;
  1460.    tag[2].ti_Tag = WA_MinWidth;
  1461.    tag[2].ti_Data = 60;
  1462.    tag[3].ti_Tag = WA_MinHeight;
  1463.    tag[3].ti_Data = 40;
  1464.    tag[4].ti_Tag = WA_MaxWidth;
  1465.    tag[4].ti_Data = -1;
  1466.    tag[5].ti_Tag = WA_MaxHeight;
  1467.    tag[5].ti_Data = -1;
  1468.    tag[6].ti_Tag = WA_SimpleRefresh;
  1469.    tag[6].ti_Data = TRUE;
  1470.    tag[7].ti_Tag = TAG_END;
  1471.  
  1472.    object = DoSuperShadow(object, class, MethodID,
  1473.                                          parent,
  1474.                                          "Method Window",
  1475.                                          NULL,
  1476.                                          NULL,
  1477.                                          tag,
  1478.                                          METHOD_END);
  1479.    if (!object)
  1480.       return NULL;
  1481.  
  1482.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1483.    mlo->class = UseObject(theClass);
  1484.    NewList(&mlo->list);
  1485.  
  1486.    if (theClass->ccl_verbs.mt_num)
  1487.    {
  1488.       struct MethodHandler *methods;
  1489.       struct MyNode *nodes;
  1490.       int i;
  1491.  
  1492.       mlo->nodes = AllocVec(sizeof(struct MyNode) * theClass->ccl_verbs.mt_num,
  1493.                             MEMF_PUBLIC);
  1494.  
  1495.       nodes = mlo->nodes;
  1496.       for (methods = theClass->ccl_verbs.mt_methods, i = 0;
  1497.            i < theClass->ccl_verbs.mt_num;
  1498.            i++, methods++)
  1499.       {
  1500.          nodes->node.ln_Name = UseString(methods->mh_methodID);
  1501.          nodes->object = methods;
  1502.          AddTail(&mlo->list, nodes);
  1503.          nodes++;
  1504.       }
  1505.  
  1506.    }
  1507.  
  1508.    ng.ng_LeftEdge = ng.ng_TopEdge = 50;
  1509.    ng.ng_Width = 300;
  1510.    ng.ng_Height = 90;
  1511.    ng.ng_Flags = PLACETEXT_ABOVE;
  1512.    tag[0].ti_Tag = GTLV_Labels;
  1513.    tag[0].ti_Data = (ULONG)&mlo->list;
  1514.    tag[1].ti_Tag = GTLV_ShowSelected;
  1515.    tag[1].ti_Data = NULL;
  1516.    tag[2].ti_Tag = TAG_END;
  1517.    strcpy(buffer, "Method list for class: ");
  1518.    strncat(buffer, theClass->ccl_name, 14);
  1519.    strcat(buffer, "...");
  1520.    DropObject(CreateInstance(NULL,
  1521.                              GADGT_CLASS,
  1522.                              META_CLASS,
  1523.                              object,
  1524.                              buffer,
  1525.                              object,
  1526.                              METH_GADGET_SELECT,
  1527.                              &ng,
  1528.                              LISTVIEW_KIND,
  1529.                              tag,
  1530.                              METHOD_END));
  1531.  
  1532.    ng.ng_TopEdge += ng.ng_Height;
  1533.    ng.ng_Height = 15;
  1534.    ng.ng_Width = 170;
  1535.    ng.ng_Flags = PLACETEXT_RIGHT;
  1536.    tag[0].ti_Tag = TAG_END;
  1537.    mlo->object1 = CreateInstance(NULL,
  1538.                                  GADGT_CLASS,
  1539.                                  META_CLASS,
  1540.                                  object,
  1541.                                  ":Controlled",
  1542.                                  object,
  1543.                                  METH_GADGET_SELECT,
  1544.                                  &ng,
  1545.                                  TEXT_KIND,
  1546.                                  tag,
  1547.                                  METHOD_END);
  1548.  
  1549.    ng.ng_TopEdge += ng.ng_Height;
  1550.    ng.ng_Height = 15;
  1551.    ng.ng_Width = 170;
  1552.    ng.ng_Flags = PLACETEXT_RIGHT;
  1553.    tag[0].ti_Tag = TAG_END;
  1554.    mlo->object2 = CreateInstance(NULL,
  1555.                                  GADGT_CLASS,
  1556.                                  META_CLASS,
  1557.                                  object,
  1558.                                  ":Defined",
  1559.                                  object,
  1560.                                  METH_GADGET_SELECT,
  1561.                                  &ng,
  1562.                                  TEXT_KIND,
  1563.                                  tag,
  1564.                                  METHOD_END);
  1565.  
  1566.    ng.ng_TopEdge += ng.ng_Height;
  1567.    ng.ng_Height = 15;
  1568.    ng.ng_Width = 170;
  1569.    ng.ng_Flags = PLACETEXT_RIGHT;
  1570.    tag[0].ti_Tag = TAG_END;
  1571.    mlo->object3 = CreateInstance(NULL,
  1572.                                  GADGT_CLASS,
  1573.                                  META_CLASS,
  1574.                                  object,
  1575.                                  ":Function address",
  1576.                                  object,
  1577.                                  METH_GADGET_SELECT,
  1578.                                  &ng,
  1579.                                  NUMBER_KIND,
  1580.                                  tag,
  1581.                                  METHOD_END);
  1582.  
  1583.    ng.ng_TopEdge += ng.ng_Height;
  1584.    ng.ng_Height = 15;
  1585.    ng.ng_Width = 170;
  1586.    ng.ng_Flags = PLACETEXT_RIGHT;
  1587.    tag[0].ti_Tag = TAG_END;
  1588.    mlo->object4 = CreateInstance(NULL,
  1589.                                  GADGT_CLASS,
  1590.                                  META_CLASS,
  1591.                                  object,
  1592.                                  ":threadStat",
  1593.                                  object,
  1594.                                  METH_GADGET_SELECT,
  1595.                                  &ng,
  1596.                                  TEXT_KIND,
  1597.                                  tag,
  1598.                                  METHOD_END);
  1599.  
  1600.    ng.ng_TopEdge = 50;
  1601.    ng.ng_LeftEdge = 370;
  1602.    ng.ng_Height = 20;
  1603.    ng.ng_Width = 100;
  1604.    ng.ng_Flags = 0;
  1605.    tag[0].ti_Tag = TAG_END;
  1606.    DropObject(CreateInstance(NULL,
  1607.                              GADGT_CLASS,
  1608.                              META_CLASS,
  1609.                              object,
  1610.                              "Arguments",
  1611.                              object,
  1612.                              METH_GADGET_OPEN_RWIN,
  1613.                              &ng,
  1614.                              BUTTON_KIND,
  1615.                              tag,
  1616.                              METHOD_END));
  1617.  
  1618.    ng.ng_TopEdge += ng.ng_Height;
  1619.    ng.ng_Height = 15;
  1620.    ng.ng_Width = 25;
  1621.    ng.ng_Flags = PLACETEXT_RIGHT;
  1622.    tag[0].ti_Tag = TAG_END;
  1623.    mlo->object5 = CreateInstance(NULL,
  1624.                                  GADGT_CLASS,
  1625.                                  META_CLASS,
  1626.                                  object,
  1627.                                  ":Patches",
  1628.                                  object,
  1629.                                  METH_GADGET_SELECT,
  1630.                                  &ng,
  1631.                                  NUMBER_KIND,
  1632.                                  tag,
  1633.                                  METHOD_END);
  1634.  
  1635.    /*
  1636.     * So watch the Patch list....
  1637.     */
  1638.    {
  1639.       mlo->director = CreateInstance(NULL,
  1640.                                      DIRECTOR_CLASS,
  1641.                                      META_CLASS,
  1642.                                      "Watch Patches",
  1643.                                      object,
  1644.                                      METH_METHOD_UPDATE_INFO,
  1645.                                        (W_INSERT_NODE | W_REMOVE) |
  1646.                                        (SHADOW_OBJECT << 16) |
  1647.                                        W_FLAG_AUTOBREAK |
  1648.                                        W_FLAG_AUTOREMOVE,
  1649.                                      METHOD_END);
  1650.       DropObject( DoShadow(mlo->director,
  1651.                                NULL,
  1652.                                METH_DIRECTOR_ESTABLISH,
  1653.                                ATTR_PATCHEDVERBS,
  1654.                                theClass,
  1655.                                METHOD_END));
  1656.    }
  1657.    return object;
  1658. }
  1659.  
  1660. void MetWinDestroyMethod(METHOD_ARGS)
  1661. {
  1662.    struct MWinLocalObjects *mlo;
  1663.    struct Node *node;
  1664.  
  1665.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1666.    DropObject(mlo->object1);
  1667.    DropObject(mlo->object2);
  1668.    DropObject(mlo->object3);
  1669.    DropObject(mlo->object4);
  1670.    DropObject(mlo->object5);
  1671.    DropObject(mlo->class);
  1672.  
  1673.    if (mlo->nodes)
  1674.    {
  1675.       for(node = mlo->list.lh_Head; node->ln_Succ; node = node->ln_Succ)
  1676.          QuickDropString(node->ln_Name);
  1677.  
  1678.       FreeVec(mlo->nodes);
  1679.    }
  1680.  
  1681.    CallSuper();
  1682. }
  1683.  
  1684. void MetWinRemoveMethod(METHOD_ARGS)
  1685. {
  1686.    struct MWinLocalObjects *mlo;
  1687.  
  1688.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1689.    RemoveObject(SetObject(&mlo->director, NULL));
  1690.    mlo->director = NULL;
  1691.  
  1692.    CallSuper();
  1693. }
  1694.  
  1695. void MetWinUpdateInfo(METHOD_ARGS)
  1696. {
  1697.    struct MWinLocalObjects *mlo;
  1698.    struct TagItem tags[2];
  1699.  
  1700.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1701.  
  1702.    tags[0].ti_Tag = GTNM_Number;
  1703.    tags[1].ti_Tag = TAG_END;
  1704.  
  1705.    /*
  1706.     * Number of Patches
  1707.     */
  1708.    tags[0].ti_Data = (ULONG)((struct MethodHandler *)
  1709.                       (mlo->lastNode->object))->mh_numPatches;
  1710.    DoShadow(mlo->object5, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1711.  
  1712. }
  1713.  
  1714. /*
  1715.  * A new METHOD has been hit, show the selected argument's information.
  1716.  */
  1717. void MetWinHitMethod(METHOD_ARGS,  struct GuiIntuiMsg *info, OBJECT window)
  1718. {
  1719.    struct MWinLocalObjects *mlo;
  1720.    struct TagItem tags[2];
  1721.    long code = (info)?info->gii_Code:0;
  1722.  
  1723.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1724.  
  1725.    mlo->lastNode = &mlo->nodes[code];
  1726.  
  1727.    tags[0].ti_Tag = GTTX_Text;
  1728.    tags[0].ti_Data = (ULONG)"";
  1729.    tags[1].ti_Tag = TAG_END;
  1730.  
  1731.    /*
  1732.     * Controlled Process Object.
  1733.     */
  1734.    {
  1735.       OBJECT obj;
  1736.       struct ShadowProcess *sp;
  1737.  
  1738.       obj = ((struct MethodHandler *)
  1739.                 (mlo->lastNode->object))->mh_procObject;
  1740.       PSem(obj, SSEM_LOCK);
  1741.       switch(((struct MethodHandler *)mlo->lastNode->object)->mh_flags &
  1742.              (METH_FLAG_PORT |METH_FLAG_OBJECT | METH_FLAG_SPEC))
  1743.       {
  1744.          case METH_FLAG_OBJECT:
  1745.             if ((sp = FindAttribute(obj, ATTR_SHADOWPROCESS)) &&
  1746.                 sp->sp_procName)
  1747.                tags[0].ti_Data = (ULONG)sp->sp_procName;
  1748.             else
  1749.                tags[0].ti_Data = (ULONG)((sp)?"NoNameProcess":
  1750.                                               ((obj)?"ILLEGAL! Object":
  1751.                                                      "No Object"));
  1752.             break;
  1753.  
  1754.          case METH_FLAG_PORT:
  1755.             if (obj && ((struct MsgPort *)obj)->mp_Node.ln_Name)
  1756.                tags[0].ti_Data = (ULONG)
  1757.                   ((struct MsgPort *)obj)->mp_Node.ln_Name;
  1758.             else
  1759.                tags[0].ti_Data = (ULONG)((obj)?"Unnamed Port":"No Port");
  1760.             break;
  1761.  
  1762.          case METH_FLAG_CLASS:
  1763.             if (obj && ((META)obj)->meta_name)
  1764.                tags[0].ti_Data = (ULONG)((META)obj)->meta_name;
  1765.             else
  1766.                tags[0].ti_Data = (ULONG)((obj)?"Unnamed Class":"No Class");
  1767.             break;
  1768.  
  1769.          case (METH_FLAG_OBJECT | METH_FLAG_SPEC):
  1770.             if (((struct MethodInvokeSpec *)obj)->mis_instanceName)
  1771.                tags[0].ti_Data = (ULONG)
  1772.                   ((struct MethodInvokeSpec *)obj)->mis_instanceName;
  1773.             else
  1774.                tags[0].ti_Data = (ULONG)"Spec has no instance name?";
  1775.             break;
  1776.          case (METH_FLAG_PORT | METH_FLAG_SPEC):
  1777.             if (((struct MethodInvokeSpec *)obj)->mis_instanceName)
  1778.                tags[0].ti_Data = (ULONG)
  1779.                   ((struct MethodInvokeSpec *)obj)->mis_instanceName;
  1780.             else
  1781.                tags[0].ti_Data = (ULONG)"Spec has no port name?";
  1782.             break;
  1783.          case (METH_FLAG_CLASS | METH_FLAG_SPEC):
  1784.             if (((struct MethodInvokeSpec *)obj)->mis_className)
  1785.                tags[0].ti_Data = (ULONG)
  1786.                   ((struct MethodInvokeSpec *)obj)->mis_className;
  1787.             else
  1788.                tags[0].ti_Data = (ULONG)"Spec has no class name?";
  1789.             break;
  1790.       }
  1791.       VSem(obj);
  1792.  
  1793.    }
  1794.    DoShadow(mlo->object1, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1795.    /*
  1796.     * Defined Process Object.
  1797.     */
  1798.    {
  1799.       OBJECT object;
  1800.       struct ShadowProcess *sp;
  1801.  
  1802.       object = ((struct MethodHandler *)
  1803.                 (mlo->lastNode->object))->mh_defnObject;
  1804.       if (sp = FindAttribute(object, ATTR_SHADOWPROCESS))
  1805.          tags[0].ti_Data = (ULONG)((sp->sp_procName)?sp->sp_procName:
  1806.                                    "NoName Process");
  1807.       else
  1808.       {
  1809.          tags[0].ti_Data = (ULONG)((object)?"non-Process Object":"No Object");
  1810.       }
  1811.    }
  1812.    DoShadow(mlo->object2, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1813.  
  1814.    /*
  1815.     * Function Address
  1816.     */
  1817.    tags[0].ti_Tag = GTNM_Number;
  1818.    tags[0].ti_Data = (ULONG)((struct MethodHandler *)
  1819.                       (mlo->lastNode->object))->mh_method;
  1820.    DoShadow(mlo->object3, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1821.  
  1822.    /*
  1823.     * Number of Patches
  1824.     */
  1825.    tags[0].ti_Tag = GTNM_Number;
  1826.    tags[0].ti_Data = (ULONG)((struct MethodHandler *)
  1827.                       (mlo->lastNode->object))->mh_numPatches;
  1828.    DoShadow(mlo->object5, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1829.  
  1830.    /*
  1831.     * ThreadStat
  1832.     */
  1833.    tags[0].ti_Tag = GTTX_Text;
  1834.    switch(((struct MethodHandler *)
  1835.           (mlo->lastNode->object))->mh_threadStat &
  1836.           (INVOKE_FORCE | INVOKE_SYNC | INVOKE_ASYNC))
  1837.    {
  1838.        case INVOKE_CALL:
  1839.           tags[0].ti_Data = (ULONG)"Function call";
  1840.           break;
  1841.        case INVOKE_SYNC:
  1842.           tags[0].ti_Data = (ULONG)"Synchronous call";
  1843.           break;
  1844.        case INVOKE_ASYNC:
  1845.           tags[0].ti_Data = (ULONG)"Asynchronous call";
  1846.           break;
  1847.        case INVOKE_FORCE_SYNC:
  1848.           tags[0].ti_Data = (ULONG)"forced synch. call";
  1849.           break;
  1850.        default:
  1851.           tags[0].ti_Data = (ULONG)"forced async. call";
  1852.           break;
  1853.    }
  1854.    DoShadow(mlo->object4, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  1855. }
  1856.  
  1857. /*
  1858.  * Open the Reference (parameter) Window.
  1859.  */
  1860. void MWinOpenRWinMethod(METHOD_ARGS)
  1861. {
  1862.    struct MWinLocalObjects *mlo;
  1863.  
  1864.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1865.  
  1866.    if (!mlo->lastNode)
  1867.       return;
  1868.  
  1869.    DropObject(CreateInstance(NULL,
  1870.                              REFWIN_CLASS,
  1871.                              META_CLASS,
  1872.                              object,
  1873.                              mlo->lastNode->object,
  1874.                              mlo->class,
  1875.                              METHOD_END));
  1876. }
  1877.  
  1878.  
  1879. /*
  1880.  * AttWin Class methods.
  1881.  */
  1882. ARGUMENT_TAG REF_AttWinInitMethod[] = {
  1883.                                        {'JOBJ', sizeof(void *),
  1884.                                                 SHADOW_OBJECT},
  1885.                                        {'JOBJ', sizeof(void *),
  1886.                                                 SHADOW_CLASS},
  1887.                                        { TAG_END, SHADOW_RETURN_OBJECT, 0}
  1888.                                     };
  1889. void *AttWinInitMethod(METHOD_ARGS, OBJECT parent,
  1890.                                     CLASS  theClass)
  1891. {
  1892.    struct NewGadget ng;
  1893.    struct TagItem tag[8];
  1894.    struct AWinLocalObjects *mlo;
  1895.    char buffer[128];
  1896.  
  1897.    tag[0].ti_Tag = WA_Width;
  1898.    tag[0].ti_Data = 500;
  1899.    tag[1].ti_Tag = WA_Height;
  1900.    tag[1].ti_Data = 200;
  1901.    tag[2].ti_Tag = WA_MinWidth;
  1902.    tag[2].ti_Data = 60;
  1903.    tag[3].ti_Tag = WA_MinHeight;
  1904.    tag[3].ti_Data = 40;
  1905.    tag[4].ti_Tag = WA_MaxWidth;
  1906.    tag[4].ti_Data = -1;
  1907.    tag[5].ti_Tag = WA_MaxHeight;
  1908.    tag[5].ti_Data = -1;
  1909.    tag[6].ti_Tag = WA_SimpleRefresh;
  1910.    tag[6].ti_Data = TRUE;
  1911.    tag[7].ti_Tag = TAG_END;
  1912.  
  1913.    object = DoSuperShadow(object, class, MethodID,
  1914.                                          parent,
  1915.                                          "Attribute Window",
  1916.                                          NULL,
  1917.                                          NULL,
  1918.                                          tag,
  1919.                                          METHOD_END);
  1920.  
  1921.    if (!object)
  1922.       return NULL;
  1923.  
  1924.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  1925.    mlo->meta = UseObject(theClass);
  1926.    NewList(&mlo->list);
  1927.  
  1928.    /*
  1929.     * Copy all of the attributes into the allocated list.
  1930.     */
  1931.    if (theClass->ccl_attributes.att_num)
  1932.    {
  1933.       struct Attribute *attrs;
  1934.       struct MyNode *nodes;
  1935.       int i;
  1936.  
  1937.       mlo->nodes = AllocVec(sizeof(struct MyNode) *
  1938.                                  theClass->ccl_attributes.att_num,
  1939.                             MEMF_PUBLIC);
  1940.  
  1941.       nodes = mlo->nodes;
  1942.       for (attrs = theClass->ccl_attributes.att_attrs, i = 0;
  1943.            i < theClass->ccl_attributes.att_num;
  1944.            i++, attrs++)
  1945.       {
  1946.          nodes->node.ln_Name = UseString(attrs->attr_name);
  1947.          nodes->object = attrs;
  1948.          AddTail(&mlo->list, nodes);
  1949.          nodes++;
  1950.       }
  1951.    }
  1952.  
  1953.    ng.ng_LeftEdge = ng.ng_TopEdge = 50;
  1954.    ng.ng_Width = 300;
  1955.    ng.ng_Height = 90;
  1956.    ng.ng_Flags = PLACETEXT_ABOVE;
  1957.    tag[0].ti_Tag = GTLV_Labels;
  1958.    tag[0].ti_Data = (ULONG)&mlo->list;
  1959.    tag[1].ti_Tag = GTLV_ShowSelected;
  1960.    tag[1].ti_Data = NULL;
  1961.    tag[2].ti_Tag = TAG_END;
  1962.    strcpy(buffer, "Attributes for class: ");
  1963.    strncat(buffer, theClass->ccl_name, 14);
  1964.    strcat(buffer, "...");
  1965.    DropObject(CreateInstance(NULL,
  1966.                              GADGT_CLASS,
  1967.                              META_CLASS,
  1968.                              object,
  1969.                              buffer,
  1970.                              object,
  1971.                              METH_GADGET_SELECT,
  1972.                              &ng,
  1973.                              LISTVIEW_KIND,
  1974.                              tag,
  1975.                              METHOD_END));
  1976.  
  1977.    ng.ng_TopEdge += ng.ng_Height;
  1978.    ng.ng_Height = 15;
  1979.    ng.ng_Width = 80;
  1980.    ng.ng_Flags = PLACETEXT_RIGHT;
  1981.    tag[0].ti_Tag = TAG_END;
  1982.    mlo->object1 = CreateInstance(NULL,
  1983.                                  GADGT_CLASS,
  1984.                                  META_CLASS,
  1985.                                  object,
  1986.                                  ":Attribute offset",
  1987.                                  object,
  1988.                                  METH_GADGET_SELECT,
  1989.                                  &ng,
  1990.                                  NUMBER_KIND,
  1991.                                  tag,
  1992.                                  METHOD_END);
  1993.  
  1994.    ng.ng_TopEdge += ng.ng_Height;
  1995.    ng.ng_Height = 15;
  1996.    ng.ng_Width = 80;
  1997.    ng.ng_Flags = PLACETEXT_RIGHT;
  1998.    tag[0].ti_Tag = TAG_END;
  1999.    mlo->object2 = CreateInstance(NULL,
  2000.                                  GADGT_CLASS,
  2001.                                  META_CLASS,
  2002.                                  object,
  2003.                                  ":size",
  2004.                                  object,
  2005.                                  METH_GADGET_SELECT,
  2006.                                  &ng,
  2007.                                  NUMBER_KIND,
  2008.                                  tag,
  2009.                                  METHOD_END);
  2010.  
  2011.    ng.ng_TopEdge += ng.ng_Height;
  2012.    ng.ng_Height = 15;
  2013.    ng.ng_Width = 80;
  2014.    ng.ng_Flags = PLACETEXT_RIGHT;
  2015.    tag[0].ti_Tag = TAG_END;
  2016.    mlo->object3 = CreateInstance(NULL,
  2017.                                  GADGT_CLASS,
  2018.                                  META_CLASS,
  2019.                                  object,
  2020.                                  ":watcher list",
  2021.                                  object,
  2022.                                  METH_GADGET_SELECT,
  2023.                                  &ng,
  2024.                                  NUMBER_KIND,
  2025.                                  tag,
  2026.                                  METHOD_END);
  2027.  
  2028.    ng.ng_TopEdge += ng.ng_Height;
  2029.    ng.ng_Height = 15;
  2030.    ng.ng_Width = 80;
  2031.    ng.ng_Flags = PLACETEXT_RIGHT;
  2032.    tag[0].ti_Tag = TAG_END;
  2033.    mlo->object4 = CreateInstance(NULL,
  2034.                                  GADGT_CLASS,
  2035.                                  META_CLASS,
  2036.                                  object,
  2037.                                  ":default object",
  2038.                                  object,
  2039.                                  METH_GADGET_SELECT,
  2040.                                  &ng,
  2041.                                  NUMBER_KIND,
  2042.                                  tag,
  2043.                                  METHOD_END);
  2044.    return object;
  2045. }
  2046.  
  2047. void AttWinDestroyMethod(METHOD_ARGS)
  2048. {
  2049.    struct AWinLocalObjects *mlo;
  2050.    struct Node *node;
  2051.  
  2052.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  2053.    DropObject(mlo->object1);
  2054.    DropObject(mlo->object2);
  2055.    DropObject(mlo->object3);
  2056.    DropObject(mlo->object4);
  2057.    DropObject(mlo->meta);
  2058.  
  2059.    if (mlo->nodes)
  2060.    {
  2061.       for(node = mlo->list.lh_Head; node->ln_Succ; node = node->ln_Succ)
  2062.          QuickDropString(node->ln_Name);
  2063.  
  2064.       FreeVec(mlo->nodes);
  2065.    }
  2066.  
  2067.    CallSuper();
  2068. }
  2069.  
  2070. /*
  2071.  * A new Attribute has been hit, show the selected argument's information.
  2072.  */
  2073. void AttWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window)
  2074. {
  2075.    struct AWinLocalObjects *mlo;
  2076.    struct TagItem tags[2];
  2077.    long code = (info)?info->gii_Code:0;
  2078.  
  2079.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  2080.  
  2081.    mlo->lastNode = &mlo->nodes[code];
  2082.  
  2083.    tags[0].ti_Tag = GTNM_Number;
  2084.    tags[0].ti_Data = ((struct Attribute *)
  2085.                       (mlo->lastNode->object))->attr_offset;
  2086.    tags[1].ti_Tag = TAG_END;
  2087.  
  2088.    /*
  2089.     * Offset.
  2090.     */
  2091.    DoShadow(mlo->object1, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  2092.  
  2093.    /*
  2094.     * Size
  2095.     */
  2096.    tags[0].ti_Data = ((struct Attribute *)
  2097.                       (mlo->lastNode->object))->attr_size;
  2098.    if (tags[0].ti_Data & FLAG_ATTR_WATCHED)
  2099.       tags[0].ti_Data = sizeof(struct WatchedTree);
  2100.    DoShadow(mlo->object2, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  2101.  
  2102.    /*
  2103.     * if watched (attr->size & FLAG_ATTR_WATCHED), then display it.
  2104.     *  else -1.
  2105.     */
  2106.    if (FLAG_ATTR_WATCHED & ((struct Attribute *)
  2107.                             (mlo->lastNode->object))->attr_size)
  2108.       tags[0].ti_Data = (ULONG)((struct Attribute *)
  2109.                       (mlo->lastNode->object))->attr_first;
  2110.    else
  2111.       tags[0].ti_Data = -1;
  2112.    DoShadow(mlo->object3, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  2113.  
  2114.    /*
  2115.     * default Object.
  2116.     */
  2117.    if (FLAG_ATTR_WATCHED & ((struct Attribute *)
  2118.                             (mlo->lastNode->object))->attr_size)
  2119.       tags[0].ti_Data = (~FLAG_ATTR_WATCHED & ((struct Attribute *)
  2120.                           (mlo->lastNode->object))->attr_size);
  2121.    else
  2122.       tags[0].ti_Data = (ULONG)((struct Attribute *)
  2123.                          (mlo->lastNode->object))->attr_value;
  2124.    DoShadow(mlo->object4, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  2125. }
  2126.  
  2127.  
  2128. /*
  2129.  * RefWin Class methods.
  2130.  */
  2131. ARGUMENT_TAG REF_RefWinInitMethod[] = {
  2132.                                        {'JOBJ', sizeof(void *),
  2133.                                                 SHADOW_OBJECT},
  2134.                                        {'MREF', sizeof(void *),
  2135.                                                 sizeof(struct MethodHandler)},
  2136.                                        {'JOBJ', sizeof(void *),
  2137.                                                 SHADOW_CLASS},
  2138.                                        {TAG_END, SHADOW_RETURN_OBJECT, 0}
  2139.                                     };
  2140. void *RefWinInitMethod(METHOD_ARGS, OBJECT parent,
  2141.                                     struct MethodHandler *method,
  2142.                                     CLASS mclass)
  2143. {
  2144.    char *name;
  2145.    char buffer[256];
  2146.    struct TagItem tag[8];
  2147.    struct NewGadget ng;
  2148.    struct RWinLocalObjects *mlo;
  2149.  
  2150.    strcpy(buffer, "Arguments to: ");
  2151.    strncat(buffer, method->mh_methodID, 200);
  2152.    name = UseString(buffer);
  2153.  
  2154.    {
  2155.       OBJECT object2;
  2156.  
  2157.       if (object2 =
  2158.            FindWatchedTreeStringNode(
  2159.               (W_AVLTREE)FindAttribute(parent, ATTR_GUICHILDREN),
  2160.               name))
  2161.       {
  2162.          struct WindowObject *wo;
  2163.  
  2164.          /*
  2165.           * The window is already up top, so pop it on top of all the
  2166.           *  windows.
  2167.           */
  2168.          if (wo = FindAttribute(object2, ATTR_WINDOW))
  2169.             WindowToFront(wo->wo_window);
  2170.  
  2171.          DropObject(object2);
  2172.          QuickDropString(name);
  2173.  
  2174.          /*
  2175.           * Destroy this object.
  2176.           */
  2177.          UseObject(object);
  2178.          DropObject(object);
  2179.          return NULL;
  2180.       }
  2181.    }
  2182.  
  2183.    tag[0].ti_Tag = WA_Width;
  2184.    tag[0].ti_Data = 500;
  2185.    tag[1].ti_Tag = WA_Height;
  2186.    tag[1].ti_Data = 200;
  2187.    tag[2].ti_Tag = WA_MinWidth;
  2188.    tag[2].ti_Data = 60;
  2189.    tag[3].ti_Tag = WA_MinHeight;
  2190.    tag[3].ti_Data = 40;
  2191.    tag[4].ti_Tag = WA_MaxWidth;
  2192.    tag[4].ti_Data = -1;
  2193.    tag[5].ti_Tag = WA_MaxHeight;
  2194.    tag[5].ti_Data = -1;
  2195.    tag[6].ti_Tag = WA_SimpleRefresh;
  2196.    tag[6].ti_Data = TRUE;
  2197.    tag[7].ti_Tag = TAG_END;
  2198.  
  2199.    object = DoSuperShadow(object, class, MethodID,
  2200.                                          parent,
  2201.                                          name,
  2202.                                          NULL,
  2203.                                          NULL,
  2204.                                          tag,
  2205.                                          METHOD_END);
  2206.    QuickDropString(name);
  2207.  
  2208.    if (!object)
  2209.       return NULL;
  2210.  
  2211.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  2212.    NewList(&mlo->list);
  2213.  
  2214.    /*
  2215.     * Copy the method-ref (argument or parameter) designations into
  2216.     *  an allocated list.
  2217.     */
  2218.    if (method->mh_num)
  2219.    {
  2220.       ARGUMENT_TAG *ref;
  2221.       struct MyNode *nodes;
  2222.  
  2223.       mlo->nodes = AllocVec(sizeof(struct MyNode) * method->mh_num,
  2224.                             MEMF_PUBLIC);
  2225.  
  2226.       nodes = mlo->nodes;
  2227.       buffer[4] = 0;
  2228.       for (ref = method->mh_args; ref->at_tag; ref++)
  2229.       {
  2230.          *((long *)buffer) = ref->at_tag;
  2231.          nodes->node.ln_Name = UseString(buffer);
  2232.          nodes->object = ref;
  2233.          AddTail(&mlo->list, nodes);
  2234.          nodes++;
  2235.       }
  2236.  
  2237.    }
  2238.  
  2239.    ng.ng_LeftEdge = ng.ng_TopEdge = 50;
  2240.    ng.ng_Width = 300;
  2241.    ng.ng_Height = 90;
  2242.    ng.ng_Flags = PLACETEXT_ABOVE;
  2243.    tag[0].ti_Tag = GTLV_Labels;
  2244.    tag[0].ti_Data = (ULONG)&mlo->list;
  2245.    tag[1].ti_Tag = TAG_END;
  2246.  
  2247.    strcpy(buffer, "method in class: ");
  2248.    if (mclass)
  2249.       strncat(buffer, mclass->ccl_name, 18);
  2250.    strcat(buffer, "...");
  2251.    name = UseString(buffer);
  2252.    DropObject(CreateInstance(NULL,
  2253.                              GADGT_CLASS,
  2254.                              META_CLASS,
  2255.                              object,
  2256.                              name,
  2257.                              object,
  2258.                              METH_GADGET_SELECT,
  2259.                              &ng,
  2260.                              LISTVIEW_KIND,
  2261.                              tag,
  2262.                              METHOD_END));
  2263.    QuickDropString(name);
  2264.  
  2265.    ng.ng_TopEdge += ng.ng_Height;
  2266.    ng.ng_Height = 15;
  2267.    ng.ng_Width = 80;
  2268.    ng.ng_Flags = PLACETEXT_RIGHT;
  2269.    tag[0].ti_Tag = TAG_END;
  2270.    mlo->object1 = CreateInstance(NULL,
  2271.                                  GADGT_CLASS,
  2272.                                  META_CLASS,
  2273.                                  object,
  2274.                                  ":size of argument",
  2275.                                  object,
  2276.                                  METH_GADGET_SELECT,
  2277.                                  &ng,
  2278.                                  NUMBER_KIND,
  2279.                                  tag,
  2280.                                  METHOD_END);
  2281.  
  2282.    ng.ng_TopEdge += ng.ng_Height;
  2283.    ng.ng_Height = 15;
  2284.    ng.ng_Width = 80;
  2285.    ng.ng_Flags = PLACETEXT_RIGHT;
  2286.    tag[0].ti_Tag = TAG_END;
  2287.    mlo->object2 = CreateInstance(NULL,
  2288.                                  GADGT_CLASS,
  2289.                                  META_CLASS,
  2290.                                  object,
  2291.                                  NULL,
  2292.                                  object,
  2293.                                  METH_GADGET_SELECT,
  2294.                                  &ng,
  2295.                                  TEXT_KIND,
  2296.                                  tag,
  2297.                                  METHOD_END);
  2298.    return object;
  2299. }
  2300.  
  2301. void RefWinDestroyMethod(METHOD_ARGS)
  2302. {
  2303.    struct RWinLocalObjects *mlo;
  2304.    struct Node *node;
  2305.  
  2306.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  2307.    DropObject(mlo->object1);
  2308.    DropObject(mlo->object2);
  2309.    DropString(mlo->text);
  2310.    if (mlo->nodes)
  2311.    {
  2312.       for(node = mlo->list.lh_Head; node->ln_Succ; node = node->ln_Succ)
  2313.          QuickDropString(node->ln_Name);
  2314.  
  2315.       FreeVec(mlo->nodes);
  2316.    }
  2317.    CallSuper();
  2318. }
  2319.  
  2320. /*
  2321.  * A new ARGUMENT_TAG has been hit, show the selected argument's information.
  2322.  */
  2323. void RefWinHitMethod(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window)
  2324. {
  2325.    struct RWinLocalObjects *mlo;
  2326.    struct TagItem tags[2];
  2327.    long code = (info)?info->gii_Code:0;
  2328.  
  2329.    mlo = FindAttribute(object, ATTR_LOCALWIN);
  2330.    mlo->lastNode = &mlo->nodes[code];
  2331.  
  2332.    tags[0].ti_Tag = GTNM_Number;
  2333.    tags[0].ti_Data = ((ARGUMENT_TAG *)(mlo->lastNode->object))->at_size;
  2334.    tags[1].ti_Tag = TAG_END;
  2335.  
  2336.    DoShadow(mlo->object1, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  2337.  
  2338.    {
  2339.       char buffer[256];
  2340.  
  2341.       switch(((ARGUMENT_TAG *)(mlo->lastNode->object))->at_tag)
  2342.       {
  2343.          case 'TAGL':
  2344.             RawDoFmt("size of tag item: %d",
  2345.                      &((ARGUMENT_TAG *)(mlo->lastNode->object))->at_flags,
  2346.                      SprintfCallback, buffer);
  2347.             break;
  2348.          case 'JOBJ':
  2349.             switch(((ARGUMENT_TAG *)(mlo->lastNode->object))->at_flags)
  2350.             {
  2351.                case SHADOW_OBJECT:
  2352.                   strcpy(buffer, "Shadow Object");
  2353.                   break;
  2354.                case SHADOW_CLASSLESSOBJECT:
  2355.                   strcpy(buffer, "Shadow Classless");
  2356.                   break;
  2357.                case SHADOW_META:
  2358.                   strcpy(buffer, "Shadow Meta");
  2359.                   break;
  2360.                case SHADOW_CLASS:
  2361.                   strcpy(buffer, "Shadow Class");
  2362.                   break;
  2363.                case SHADOW_CLUSTER:
  2364.                   strcpy(buffer, "Shadow Cluster");
  2365.                   break;
  2366.                case SHADOW_COMPOSITE:
  2367.                   strcpy(buffer, "Shadow Composite");
  2368.                   break;
  2369.                default:
  2370.                   strcpy(buffer, "unknown/unspecified");
  2371.                   break;
  2372.             }
  2373.             break;
  2374.          case 'JSTR':
  2375.             strcpy(buffer, "String");
  2376.             break;
  2377.          default:
  2378.             RawDoFmt("size of pointer? : %d",
  2379.                      &((ARGUMENT_TAG *)(mlo->lastNode->object))->at_flags,
  2380.                      SprintfCallback, buffer);
  2381.       }
  2382.  
  2383.       DropString(mlo->text);
  2384.       mlo->text = UseString(buffer);
  2385.    }
  2386.  
  2387.    tags[0].ti_Tag = GTTX_Text;
  2388.    tags[0].ti_Data = (ULONG)mlo->text;
  2389.    DoShadow(mlo->object2, NULL, METH_GADGET_CHANGE, tags, METHOD_END);
  2390.  
  2391. }
  2392.